package org.mch.func.str.replace;

import java.awt.BorderLayout;
import java.awt.Font;

import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;

import org.fife.ui.rtextarea.RTextArea;
import org.mch.biz.ui.FuncEvent;
import org.mch.biz.ui.FuncPanel;
import org.mch.swingm.core.MButton;

/**
 * 描述：字符串替换；<BR/>
 * 
 * @author mch
 *
 */
public class ClientPanel extends FuncPanel {
	private static final long serialVersionUID = 1L;
	private JSplitPane splitPane;
	private JPanel panel;
	private JPanel panel_1;
	private JSplitPane splitPane_1;
	private JScrollPane scrollPane;
	private RTextArea text_template;
	private MButton btn_execute;
	private JSplitPane splitPane_2;
	private JScrollPane scrollPane_1;
	private JScrollPane scrollPane_2;
	private RTextArea text_repitem;
	private RTextArea text_outresult;

	public ClientPanel() {
		initComponents();
	}

	private void initComponents() {
		setLayout(new BorderLayout(0, 0));
		add(getSplitPane(), BorderLayout.CENTER);
	}

	protected FuncEvent createEvent() {
		return new ClientEvent(this);
	}

	public JSplitPane getSplitPane() {
		if (splitPane == null) {
			splitPane = new JSplitPane();
			splitPane.setDividerSize(3);
			splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
			splitPane.setLeftComponent(getPanel_1());
			splitPane.setRightComponent(getPanel_1_1());
			splitPane.setDividerLocation(50);
		}
		return splitPane;
	}

	public JPanel getPanel_1() {
		if (panel == null) {
			panel = new JPanel();
			panel.setLayout(null);
			panel.add(getBtn_execute());
		}
		return panel;
	}

	public JPanel getPanel_1_1() {
		if (panel_1 == null) {
			panel_1 = new JPanel();
			panel_1.setLayout(new BorderLayout(0, 0));
			panel_1.add(getSplitPane_1(), BorderLayout.CENTER);
		}
		return panel_1;
	}

	public JSplitPane getSplitPane_1() {
		if (splitPane_1 == null) {
			splitPane_1 = new JSplitPane();
			splitPane_1.setDividerSize(5);
			splitPane_1.setOrientation(JSplitPane.VERTICAL_SPLIT);
			splitPane_1.setLeftComponent(getScrollPane());
			splitPane_1.setRightComponent(getSplitPane_2());
			splitPane_1.setDividerLocation(200);
		}
		return splitPane_1;
	}

	public JScrollPane getScrollPane() {
		if (scrollPane == null) {
			scrollPane = new JScrollPane();
			scrollPane.setViewportView(getText_template());
		}
		return scrollPane;
	}

	public RTextArea getText_template() {
		if (text_template == null) {
			text_template = new RTextArea();
			text_template.setFont(new Font("宋体", Font.PLAIN, 13));
			text_template.setColumns(10);
		}
		return text_template;
	}

	public MButton getBtn_execute() {
		if (btn_execute == null) {
			btn_execute = new MButton("执行");
			btn_execute.setBounds(12, 12, 102, 25);
			btn_execute.addActionListener(getEvent());
		}
		return btn_execute;
	}

	public JSplitPane getSplitPane_2() {
		if (splitPane_2 == null) {
			splitPane_2 = new JSplitPane();
			splitPane_2.setDividerSize(5);
			splitPane_2.setLeftComponent(getScrollPane_1());
			splitPane_2.setRightComponent(getScrollPane_2());
			splitPane_2.setDividerLocation(300);
		}
		return splitPane_2;
	}

	public JScrollPane getScrollPane_1() {
		if (scrollPane_1 == null) {
			scrollPane_1 = new JScrollPane();
			scrollPane_1.setViewportView(getText_repitem());
		}
		return scrollPane_1;
	}

	public JScrollPane getScrollPane_2() {
		if (scrollPane_2 == null) {
			scrollPane_2 = new JScrollPane();
			scrollPane_2.setViewportView(getText_outresult());
		}
		return scrollPane_2;
	}

	public RTextArea getText_repitem() {
		if (text_repitem == null) {
			text_repitem = new RTextArea();
			text_repitem.setFont(new Font("宋体", Font.PLAIN, 13));
			text_repitem.setColumns(10);
		}
		return text_repitem;
	}

	public RTextArea getText_outresult() {
		if (text_outresult == null) {
			text_outresult = new RTextArea();
			text_outresult.setFont(new Font("宋体", Font.PLAIN, 13));
			text_outresult.setColumns(10);
		}
		return text_outresult;
	}
}